<?php
Zend_Loader::loadFile('../application/default/models/Common.php');
class Form_homepage extends Zend_Form
{
    public function __construct($options=array())
    {
        parent::__construct($options);
        Zend_Loader::loadClass('Homepage', array('../application/admin/models/'));
        Zend_Loader::loadClass('Blog', array('../application/admin/models/'));
        
        $blg= new Blog();
        $hm= new Homepage();
         
        $section_arr = $hm->gethomepagesections();
        
        $sub_section_arr = $options['subsect_arr'];
        $blogarr=$blg->listblogsforhome();

      	$this->setName("homecontentform");
      	$this->setAttrib('id', 'homecontentform');
     	// $this->setID("blogpostingform");
        $this->setMethod('post');
        if($options["action"]=="add" || $options["action"]=="doadd")
        {
        	$this->setAction('/admin/homepage/doadd/');
        } else if($options["action"] == "addtabcontent" || $options["action"] == "doaddtabcontent") {
        	$this->setAction('/admin/homepage/doaddtabcontent/');
        }
        else{
            $this->setAction('/admin/homepage/doedit/');
        }
        
        $this->addPrefixPath('AML_Form_Element', '../library/Form/Element/', 'element');

     	$title = new Zend_Form_Element_Text('title');
        $title ->setLabel('Title* :')
          
          ->setRequired(true)
          ->setAllowEmpty(false)
          ->setOptions(array('class'=>'inputbox'));
           $this->addElement($title);

        if($options["action"]=="add" || $options["action"]=="doadd")
        {
            $blog = new Zend_Form_Element_Select('blog');
            $blog ->setLabel('Add content from a blog  :');
            $blog->addMultiOptions(array(""=>"select blog"));
            foreach ($blogarr as $arr) {
                $blog->addMultiOption($arr['id'], $arr['title']);
            }
             $blog ->setAttrib('onchange','getcontent()');
                    $blog->setOptions(array('class'=>'inputbox'));
                    $this->addElement($blog);
          }
            

      	 $this->addElement('formRTE', 'content',
    				array('label' =>'Content',
    					'validators' =>array(
    					array('validator' =>'StringLength', 'options' =>array(0, 1000)),
                                       
    				),
                                 
		));

       
         
        $section = new Zend_Form_Element_Select('section');
        $section ->setLabel('Section* :');
        $section->setRequired(true);
		$section->addMultiOptions(array(""=>"select section"));
		$section->setAttrib('onchange', 'getHomepageSubSection()');
        foreach ($section_arr as $arr) {
            $section->addMultiOption($arr['id'], $arr['title']);
        }
		$section->setOptions(array('class'=>'inputbox'));
		$this->addElement($section);
		
		$sub_section = new Zend_Form_Element_Select('sub_section');
        $sub_section ->setLabel('Sub Section* :');
        $sub_section->setRequired(true);
		$sub_section->addMultiOptions(array(""=>"select sub section"));	
		
		foreach ($sub_section_arr as $arr) {
            $sub_section->addMultiOption($arr['id'], $arr['title']);
        }
        		
		$sub_section->setRegisterInArrayValidator(false);
		$sub_section->setOptions(array('class'=>'inputbox'));
		$this->addElement($sub_section);

                
     
      	$status = new Zend_Form_Element_Select('isactive');
        $status ->setLabel('Status* :')
          ->setRequired(true)
		 			 ->addMultiOptions(array(
		 			    '' => 'Select Status',
						1 => 'Active',
						0 => 'Deactive'));
		$status->setOptions(array('class'=>'inputbox'));
		$this->addElement($status);

       

       $this->addElement('hidden', 'id', array(
     
        'filters'    => array('StringTrim'),
        'class'			 => 'inputbox',
        'validators' => array(
        array('validator' => 'StringLength', 'options' => array(0, 50))
        )
        ));


  }

		
 

    
}
